package cn.rongdao.jrkabao.ui.city.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.bean.city.CityListBean;


/**
 * Created by jiang on 2016/6/11
 */
public class GradViewHotCityAdapter extends BaseAdapter {

    private Context mContext = null;
    private List<CityListBean.DataBean> list;

    public GradViewHotCityAdapter(Context mContext, List<CityListBean.DataBean> banks) {
        this.mContext = mContext;
        this.list = banks;
    }


    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public int getItemViewType(int position) {
        if (position < 4) {
            return 1;
        } else {
            return 2;
        }
    }

    @Override
    public int getViewTypeCount() {
        return 1;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = View.inflate(mContext, R.layout.item_city_hot_city, null);
            holder.mName = (TextView) convertView.findViewById(R.id.item_city_hot_cityname);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.mName.setText(list.get(position).getName());
        return convertView;
    }

    final static class ViewHolder {
        TextView mName;
    }

}
